{% extends 'base/base.html' %}

{% block title %}登录 - 多用户报警系统{% endblock %}

{% block content %}
<div class="row justify-content-center">
    <div class="col-md-6">
        <div class="card">
            <div class="card-header">
                <div class="d-flex justify-content-center align-items-center mb-4">
                    <i class="fa fa-bell-o" aria-hidden="true" style="font-size: 2rem; color: #1677ff; margin-right: 10px;"></i>
                    <h3 class="text-center">用户登录</h3>
                </div>
            </div>
            <div class="card-body">
                <form method="post">
                    {% csrf_token %}
                    {% if form.errors %}
                        <div class="alert alert-danger" role="alert">
                            <i class="fa fa-exclamation-circle" aria-hidden="true"></i> 用户名或密码错误，请重新输入。
                        </div>
                    {% endif %}
                    <div class="mb-3">
                        <label for="id_username" class="form-label">
                            <i class="fa fa-user-o" aria-hidden="true"></i> 用户名
                        </label>
                        {{ form.username }}
                        {% if form.username.errors %}
                            <div class="text-danger mt-1">
                                {% for error in form.username.errors %}
                                    <i class="fa fa-exclamation-triangle" aria-hidden="true"></i> {{ error }}
                                {% endfor %}
                            </div>
                        {% endif %}
                    </div>
                    <div class="mb-3">
                        <label for="id_password" class="form-label">
                            <i class="fa fa-lock" aria-hidden="true"></i> 密码
                        </label>
                        {{ form.password }}
                        {% if form.password.errors %}
                            <div class="text-danger mt-1">
                                {% for error in form.password.errors %}
                                    <i class="fa fa-exclamation-triangle" aria-hidden="true"></i> {{ error }}
                                {% endfor %}
                            </div>
                        {% endif %}
                    </div>
                    <div class="d-grid gap-2">
                        <button type="submit" class="btn btn-primary btn-lg">
                            <i class="fa fa-sign-in" aria-hidden="true"></i> 登录
                        </button>
                    </div>
                </form>
                <!-- 系统仅允许超级管理员通过控制台添加用户 -->
            </div>
        </div>
    </div>
</div>
{% endblock %}

{% block javascript %}
<script>
    // 添加页面加载动画效果
    document.addEventListener('DOMContentLoaded', function() {
        // 为表单元素添加焦点效果
        const formInputs = document.querySelectorAll('.form-control');
        formInputs.forEach(input => {
            input.addEventListener('focus', function() {
                this.parentElement.classList.add('shadow-sm');
            });
            input.addEventListener('blur', function() {
                this.parentElement.classList.remove('shadow-sm');
            });
        });
    });
</script>
{% endblock %}